#define  _CRT_SECURE_NO_WARNINGS 1
class Solution {
    public int distanceTraveled(int mainTank, int additionalTank) {
        int sum = 0;
        if (mainTank < 5) {
            return 10 * mainTank;
        }
        while (mainTank >= 5 && additionalTank >= 1) {
            sum += 50;
            mainTank = mainTank - 5 + 1;
            additionalTank -= 1;
        }
        return sum + mainTank * 10;
    }
}
class Solution {
    public int findValueOfPartition(int[] nums) {
        Arrays.sort(nums);
        int min = nums[1] - nums[0];
        int i = 1;
        for (int j = 2; j < nums.length; j++) {
            if (min > nums[j] - nums[i]) {
                min = nums[j] - nums[i];
            }
            i++;
        }
        return min;

    }
}
class Solution {
    public static final int MOD = (int)1e9 + 7;
    public int[][] f = new int[1 << 14][14];
    public int n;

    public int dfs(int i, int j, int[] nums) {
        if (i == 0) return 1;
        if (f[i][j] > 0) return f[i][j];
        int res = 0;
        for (int k = 0; k < n; k++) {
            if (((i >> k) & 1) == 1 && (nums[j] % nums[k] == 0 || nums[k] % nums[j] == 0)) {
                res = (res + dfs(i ^ (1 << k), k, nums)) % MOD;
            }
        }
        return f[i][j] = res % MOD;
    }

    public int specialPerm(int[] nums) {
        int ans = 0;
        n = nums.length;
        for (int i = 0; i < n; i++) {
            ans = (ans + dfs(((1 << n) - 1) ^ (1 << i), i, nums)) % MOD;
        }
        return ans % MOD;
    }
}